<template>
  <page-layout>
    <a-row :gutter="[10, 10]">
      <a-card>
        <div class="mb-20 box-hor-end">
          <a-button type="primary"  @click="gotoEdit">
            编辑
          </a-button>
        </div>
        <a-descriptions title="">
          <a-descriptions-item label="联系人姓名">{{ state.detailForm.contactsName || '-' }}</a-descriptions-item>
          <a-descriptions-item label="所属部门">{{ state.detailForm.contactsDepartment || '-' }}</a-descriptions-item>
          <a-descriptions-item label="职位">{{ state.detailForm.contactsPosition || '-' }}</a-descriptions-item>
          <a-descriptions-item label="所属学校">{{ state.detailForm.schName || '-' }}</a-descriptions-item>
          <a-descriptions-item label="负责人">{{ state.detailForm.responsiblePerson || '-' }}</a-descriptions-item>
          <a-descriptions-item label="电话">{{ state.detailForm.contactsPhone || '-' }}</a-descriptions-item>
          <a-descriptions-item label="Email">{{ state.detailForm.contactsEmail || '-' }}</a-descriptions-item>
          <a-descriptions-item label="性别">{{ state.detailForm.contactsSex || '-' }}</a-descriptions-item>
          <a-descriptions-item label="状态">{{ state.detailForm.contactsState || '-' }}</a-descriptions-item>
          <a-descriptions-item label="办公司地址">{{ state.detailForm.contactsOfficeAddress || '-' }}</a-descriptions-item>
          <a-descriptions-item label="创建人">{{ state.detailForm.createBy || '-' }}</a-descriptions-item>
          <a-descriptions-item label="创建时间">{{ state.detailForm.createTime || '-' }}</a-descriptions-item>
        </a-descriptions>
      </a-card>
    </a-row>
  </page-layout>
</template>

<script setup>
import { selectById } from "@/api/module/contact-manage";
import {onMounted, reactive} from "vue";
import {useRoute, useRouter} from "vue-router"
import {message} from "ant-design-vue";

const route = useRoute()
const router = useRouter()
let state = reactive({
  detailForm: {
    contactsName: '',
    contactsDepartment: '',
    contactsPosition: '',
    schName: '',
    responsiblePerson: '',
    contactsPhone: '',
    contactsEmail: '',
    contactsSex: null,
    contactsState: null,
    contactsOfficeAddress: '',
  }
})

const gotoEdit = () => {
  router.push({
    path: '/university/contact-manage/add',
    query: {
      id: route.query.id
    }
  })
}

onMounted(() => {
  if (route.query.id) {
    selectById({id: route.query.id}).then(res => {
      if (res.code === 200) {
        state.detailForm = {
          ...state.detailForm,
          ...res.data
        }
      }
      if (res.code === 500) return message.error(res.msg || '新增失败，服务器错误')
    })
  }
})

</script>

<style scoped>

</style>
